package com.jwell.panrank.model

import com.jwell.driverapp.tools.BaseSubscriber
import com.jwell.panrank.application.App
import com.jwell.panrank.contract.ForgetPasswordContract
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * Created by 76577 on 2018/4/4.
 * 忘记密码
 */
class ForgetPasswordModel : ForgetPasswordContract.Model, BaseModel() {
    override fun regSendMsg(phone: String, userType: Int, baseSubscriber: BaseSubscriber) {
        val requestData = RegSendMsg(phone, userType)
        if (App.DEBUG) println("重置密码获取验证码--" + requestData.toString())
        getApiStore().regSendMsg(requestData)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(baseSubscriber)
    }

    override fun userRegPwd(phone: String, msgCode: String, pwd: String, userType: Int, baseSubscriber: BaseSubscriber) {
        val requestData = UserRegPwd(phone, msgCode, pwd, userType)
        if (App.DEBUG) println("重置密码--" + requestData.toString())
        getApiStore().userRegPwd(requestData)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(baseSubscriber)
    }

    data class RegSendMsg(var phone: String? = null,
                          var userType: Int? = null)

    data class UserRegPwd(var phone: String? = null,
                          var msgCode: String? = null,
                          var pwd: String? = null,
                          var userType: Int? = null)
}